import { createRouter, createWebHashHistory } from 'vue-router'
const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        //主页
        {
            path: '/',
            name: 'layout',
            component: () => import('@/views/LayOut/MainHome.vue'),
            children: [
                {
                    path: '',
                    name: 'home',
                    component: () => import('@/views/Home/index.vue')
                },
                //一级分类
                {
                    path: '/category/:id',
                    name: 'category',
                    component: () => import('@/views/Category/category.vue')
                },
                //二级分类
                {
                    path: '/category/sub/:id',
                    name: 'subCategory',
                    component: () => import('@/views/SubCategory/index.vue')
                },
                //商品详情
                {
                    path: '/detail/:id',
                    name: 'detail',
                    component: () => import('@/views/Detail/index.vue'),
                },
                //购物车
                {
                    path: '/cartlist',
                    name: 'cart',
                    component: () => import('@/views/CartList/index.vue')
                },
                //结算页
                {
                    path: '/checkout',
                    name: 'settlement',
                    component: () => import('@/views/Checkout/index.vue')
                },
                //支付页
                {
                    path: '/payment',
                    name: 'payment',
                    component: () => import('@/views/Pay/index.vue')
                },
                //完成订单页
                {
                    path: '/paycallback',
                    name: 'order',
                    component: () => import('@/views/Pay/PayBack.vue')
                },
                //个人中心
                {
                    path: '/member',
                    name: 'member',
                    component: () => import('@/views/Member/index.vue'),
                    children: [
                        {
                            path: '',
                            name: 'memberHome',
                            component: () => import('@/views/Member/components/UserInfo.vue')
                        },
                        {
                            path: 'order',
                            name: 'order',
                            component: () => import('@/views/Member/components/UserOrder.vue')
                        }
                    ]
                },
            ]
        },
        //关于我们
        {
            path: '/user',
            name: 'userDetail',
            component: () => import('@/views/aboutus/AboutHome.vue'),
            children: [
                {
                    path: '/aboutus',
                    name: 'aboutus',
                    component: () => import('@/views/aboutus/index.vue'),
                    children: [
                        {
                            path: 'cate1',
                            name: 'cate1',
                            component: () => import('@/views/aboutus/cate/cate1.vue'),
                        },
                        {
                            path: 'cate2',
                            name: 'cate2',
                            component: () => import('@/views/aboutus/cate/cate2.vue'),
                            params: {
                                id: 2
                            }
                        },
                        {
                            path: 'cate3',
                            name: 'cate3',
                            component: () => import('@/views/aboutus/cate/cate3.vue'),
                            params: {
                                id: 3
                            }
                        },
                        {
                            path: 'cate4',
                            name: 'cate4',
                            component: () => import('@/views/aboutus/cate/cate4.vue')
                        },
                        {
                            path: 'cate5',
                            name: 'cate5',
                            component: () => import('@/views/aboutus/cate/cate5.vue')
                        },
                        {
                            path: 'cate6',
                            name: 'cate6',
                            component: () => import('@/views/aboutus/cate/cate6.vue')
                        },
                        {
                            path: 'cate7',
                            name: 'cate7',
                            component: () => import('@/views/aboutus/cate/cate7.vue')
                        },
                        {
                            path: 'cate8',
                            name: 'cate8',
                            component: () => import('@/views/aboutus/cate/cate8.vue')
                        },
                        {
                            path: 'cate9',
                            name: 'cate9',
                            component: () => import('@/views/aboutus/cate/cate9.vue')
                        },
                        {
                            path: 'cate10',
                            name: 'cate10',
                            component: () => import('@/views/aboutus/cate/cate10.vue')
                        },
                        {
                            path: 'cate11',
                            name: 'cate11',
                            component: () => import('@/views/aboutus/cate/cate11.vue')
                        },
                        {
                            path: 'cate12',
                            name: 'cate12',
                            component: () => import('@/views/aboutus/cate/cate12.vue')
                        },
                        {
                            path: 'cate13',
                            name: 'cate13',
                            component: () => import('@/views/aboutus/cate/cate13.vue')
                        }
                    ],
                },
                //开通会员
                {
                    path: '/vip',
                    name: 'vip',
                    component: () => import('@/views/Vip/index.vue')
                },
                //特惠推荐
                {
                    path:'/specialRecommend/1001',
                    name:'specialRecommend',
                    component: () => import('@/views/Home/recommend/specialrecommend.vue')
                },
                //爆款推荐
                {
                    path:'/specialRecommend/1002',
                    name:'explosiveRecommend',
                    component: () => import('@/views/Home/recommend/explosiveRecommend.vue')
                },
                //一站全买
                {
                    path:'/specialRecommend/1003',
                    name:'BuyAll',
                    component: () => import('@/views/Home/recommend/BuyAll.vue')
                },
                //优惠券中心
                {
                    path:'/specialRecommend/1004',
                    name:'couponCenter',
                    component: () => import('@/views/Home/recommend/couponCenter.vue')
                }
            ],
        },
        //登录页
        {
            path: '/login',
            name: 'login',
            component: () => import('@/views/Login/UserLogin.vue')
        },
        //404页面
        {
            path: '/404',
            name: 'notFound',
            component: () => import('@/views/404/index.vue')
        },
        //直播页面
        {
            path: '/live',
            name: 'live',
            component: () => import('@/views/live/index.vue')
        },
        //视频页
        {
            path: '/video',
            name: 'video',
            component: () => import('@/views/video/index.vue')
        },
        //音乐页
        {
            path: '/music',
            name:'music',
            component: () => import('@/views/music/index.vue')
        }
    ],
    //路由滚动定制
    scrollBehavior(to, from, savedPosition) {
        return {
            top: 0,
            behavior: 'smooth'   //平滑滚动
        }
    }
})

export default router